<?php

$templateData = array(
    'title'             => $this->title,
    'resourceUri'       => $this->resourceUri,
    'description'       => $this->description,
    'descriptionHelper' => $this->descriptionHelper,
    'options'           => $this->options
);

$depiction = null;
if (isset($this->description['http://xmlns.com/foaf/0.1/depiction'][0]['value'])) {
    $depiction = $this->description['http://xmlns.com/foaf/0.1/depiction'][0]['value'];
}

$toolDescription = array();
if (!$depiction && isset($this->description['http://lod2.eu/schema/demoOf'][0]['value'])) {
    $tool = $this->description['http://lod2.eu/schema/demoOf'][0]['value'];
    $toolInstance = new OntoWiki_Resource($tool, OntoWiki::getInstance()->selectedModel);
    $toolDescription = $toolInstance->getDescription();
    $toolDescription = $toolDescription[$toolInstance->getUri()];
    
    if (isset($toolDescription['http://xmlns.com/foaf/0.1/depiction'][0]['value'])) {
        $depiction = $toolDescription['http://xmlns.com/foaf/0.1/depiction'][0]['value'];
    }
}

?>
<div class="result">
    <h4><a href="<?php echo $this->url($this->resourceUri); ?>"><?php echo $this->title; ?></a></h4>
    <?php if ($depiction): ?>
        <a href="<?php echo $this->url($this->resourceUri); ?>">
            <img style="width:100%" src="<?php echo $depiction; ?>" title="depiction of <?php echo  $this->title; ?>"/>
        </a>
    <?php endif; ?>
</div>
